/*
  NSUserDefaultsAdditions.m
  QuickScale
  
  Created by Pieter Omvlee on 15-7-07.
  Copyright 2007 CocoaDig. All rights reserved.
*/

#import "CHUserDefaultsControllerAdditions.h"

@implementation NSUserDefaultsController (CHUserDefaultsAdditions)

+ (id)registerObject:(id)value forKey:(NSString *)key
{
  NSUserDefaults *defs = [[NSUserDefaultsController sharedUserDefaultsController] defaults];
  if (![defs objectForKey:key]) [defs setObject:value forKey:key];
  return [defs objectForKey:key];
}

+ (int)registerInt:(int)value forKey:(NSString *)key
{
  return [[self registerObject:[NSNumber numberWithInt:value] forKey:key] intValue];
}

+ (float)registerFloat:(float)value forKey:(NSString *)key
{
  return [[self registerObject:[NSNumber numberWithFloat:value] forKey:key] floatValue];
}

+ (BOOL)registerBool:(BOOL)value forKey:(NSString *)key
{
  return [[self registerObject:[NSNumber numberWithBool:value] forKey:key] boolValue];
}

@end
